package javase2.day01.demo01;

import java.util.Objects;

/*
Objects中equals方法：
public static boolean equals(Object a, Object b) {
        return (a == b) || (a != null && a.equals(b));
    }
优点：避免空指针异常
 */
public class DemoObjects {
    public static void main(String[] args) {
        String str1=null;
        String str2="bbb";
//        boolean result1=str1.equals(str2);
//        System.out.println(result1);//NullPointerException

        //使用Objects中equals
        boolean result2=Objects.equals(str1,str2);
        System.out.println(result2);//false


    }
}
